Lighting is a big part of rendering. There are static lights and dynamic lights and they tend to be heavy and require a lot of computing.
Static Lighting
Static lights are pre-computed in the editor and saved in a lightmap.
- 〇 : Good performance and quality (Depends on the lightmap
- ✕ : It takes time to compute and require a lot of memory
- ❕: Lights need to be re-rendered every time you make a change
- ❕: Every object needs a lightmap
What is a lightmap
It is a texture that Unreal Engine generates by a calculation called \’lightmass\’. You can control the resolution of lightmass using World Setting. You can define where you want to have high quality of lighting by putting a \’Lightmass Importance Volume\’ in your scene. Outside of the box (volume) will have lower quality of lighting.
Also, resolution of lightmaps have an impact on Memory. You can visualize UV coordinates of lightmaps at Optimization Viewmodes > Lightmap Density
Then you could find problems like \’Maybe the resolution of this lightmap is too high considering how far this object is from a player\’. However, you don\’t need to worry too much about setting this up perfect.
Dynamic Lighting
Dynamic light is rendered in real-time. It uses G-buffer images and blend them to visualize lighting. It have a big impact non performance so you need to understand well in order to use it properly.
- 〇:Sharp and natural look. It is not tied to the size of objects unlike static lights since it does not require lightmaps
- ✕:Big impact on performance
Dynamic Shadow
- ✕:Big impact on performance
- ✕:No radiosity and no global illumination
- ❕:Recommended to turn off \’Cast Shadow\’ on some lights
1. Cascade Shadow Maps (CSM)
- Fades in/out shadows as it goes far away from the camera.
- ✕:Not great for open world games
- ❕:Directional light only
2. Distance Field Shadow (DF)
- *Off by default
-
- 〇:Great performance, acculate lighting for objects in the distance
- ✕:Low quality
- There are some things that stand out even if you fade out shadows using CSM such as having no shadow at all for buildings far in distance. This is where DF comes in handy. You can turn it on by searching \’Distance\’ in Project Setting and check \’Generate Mesh Distance Fields\’.
3. Inset Shadow (= Per Object Shadow)
- You can cast high resolution shadow even if there is no proper light nearby.
- Most of the time it\’s on for characters.
4. Contact Shadow
- Not frequently used. Good for small objects and it casts shadow on the bottom contact surface.
5. Capsule Shadow
- Not frequently used. Renders shadows under objects at low cost by casting shadows using objects that have fewer polygons than real objects.
Summary
Dynamic lighting itself does not have a huge impact on performance. Shadow tends to be problems more often because shadow is calculated by pixel shader and the more you have pixel shader calculations, the more it takes time to render. That is why the radius of lights is smaller the better and performance will improve if lights are not duplicated too much. Pixel shader is computing within the white line area in the image below. You need to reduce the radius in order to minimize the cost if it\’s not necessary.
If you don\’t need shadow in the first place, you could just turn off . Also you need to be careful about poly counts when you use a lot of dynamic lights. If you can\’t cut down poly counts, you can optimize by using Distance Field Shadow.
Light Mobility
1. Movable *Dynamic Light
- × Shadow is too sharp and shows polygon lines
- × No radiosity and no global illumination
2. Stationary *Blend between Dynamic and Static
- It\’s created by blending pre-computed static light and dynamic light.
- 〇:More realistic and soft looking
3. Static *Static Light
- 〇:Fastest to render
Case study
1:Room full with lights and shadows
Use blueprint to enable the lights and shadows when a player opens the door or enter the room.
2:Need maximum performance for VR etc
Use only static lights
3:Need to change light in game freely
Use dynamic lights
thanks for the tips!
TelesphorosGames